; Music of Hopper Copper (1989) (Firebird) (Jason C. Brooke)
; Ripped by Megachur the 03/02/2008

	write "HOPPERCO.BIN"

music_date_rip	equ &0328
music_adr	equ &8000
first_theme	equ 0
last_theme	equ 0

	read "music_header_v1_0.asm"

;org #8393
;db " SND Module (C) 1986-1988 Jas.C.Brooke. This version was completed 20th July 1988. First version written June 1988"

;
.play_music
;
	push ix
	ld a,#00
.l8005 equ $ + 1
	add #00
	ld (l8005),a
	jr c,l805d
	ld ix,l8394
	ld a,(l825a)
	or a
	jr z,l802e
.l8016 equ $ + 1
	ld a,#00
	add #00
.l801a equ $ + 1
	add #00
	ld (l801a),a
	jr nc,l802e
	ld b,#00
	call l810f
	call l810d
	call l810d
	ld lx,l8394	;#94
.l802f equ $ + 1
.l802e
	ld a,#00
	ld (l803d),a
	call l8252
	call l8250
	call l8250
.l803d equ $ + 1
	ld a,#00
	ld c,#06
	call l8324
	ld hl,l8396
	ld a,#fe
	or (hl)
	dec l
	ld c,(hl)
	dec l
	rr c
	rla
	ld c,(hl)
	rr c
	rla
	ld c,a
	add a
	add a
	add a
	xor c
	ld c,#07
	call l8324
.l805d
	pop ix
	ret
;
.stop_music
.l8060
;
	sub a
	ld (l825a),a
	push bc
	push de
	ld bc,l8403
	ld (bc),a
	inc bc
	ld (bc),a
	inc bc
	ld (bc),a
	ld e,#08
	call l8323
	call l8322
	call l8322
	pop de
	pop bc
	ret
;
.jumps_table
;
	db #e5,#7c,#48,#70,#73,#10,#59,#84
	db #06,#3a,#7d,#77,#32,#25
	pop hl
	sub a
	ld (l825a),a
	jr l802e
	ld a,(ix+#15)
	ld l,(ix+#09)
	ld h,(ix+#0c)
	add #02
	cp (ix+#0f)
	jr c,l80a4
	ld a,(ix+#12)
.l80a4
	ld c,a
	add hl,bc
	ld e,(hl)
	inc l
	ld d,(hl)
	ld (ix+#15),a
	jr l8125
	ld a,(de)
	ld (ix+#4e),a
	inc de
	ld a,(de)
	ld (ix+#51),a
	inc de
	jr l8125
	ld (ix+#33),a
	jr l8125
	ld a,(de)
	inc de
	ld (ix+#48),a
	jr l8125
	ld a,(de)
	inc de
	ld (ix+#24),a
	ld a,(de)
	inc de
	ld (ix+#27),a
	ld a,(de)
	inc de
	ld (ix+#2a),a
	set 3,(ix+#4b)
	jr l8125
	ld a,(de)
	inc de
	ld (ix+#42),a
	ld a,(de)
	inc de
	ld (ix+#45),a
	add a
	ld (ix+#3f),a
	set 4,(ix+#4b)
	jr l8125
	set 7,(ix+#4b)
	set 6,(ix+#4b)
	jr l8125
	ld (ix+#4b),b
	jr l8125
	ld a,(de)
	inc de
	ld (l8302),a
	set 2,(ix+#4b)
	set 1,(ix+#4b)
	jr l8125
.l810d
	inc lx
.l810f
	dec (ix+#2d)
	ld a,(ix+#4b)
	jr nz,l8155
	and #30
	ld (ix+#4b),a
	ld (ix+#33),a
	ld e,(ix+#03)
	ld d,(ix+#06)
.l8125
	ld a,(de)
	inc de
	cp #b0
	jr c,l8149
	add #20
	jr c,l813e
	add #20
	jr c,l8144
	ld c,a
	ld hl,l8407
	add hl,bc
	ld c,(hl)
	ld (ix+#1e),c
	jr l8125
.l813e
	inc a
	ld (ix+#30),a
	jr l8125
.l8144
	ld (ix+#3c),a
	jr l8125
.l8149
	or a
	jp p,l816d
	ld c,a
	ld hl,jumps_table-&80		;#7ffc
	add hl,bc
	ld c,(hl)
	add hl,bc
	jp (hl)
.l8155
	add a
	ret p
	sbc a
	or #01
	add (ix+#33)
	ld (ix+#33),a
	ret
	bit 0,(ix+#6f)
	jr nz,l81a1
	ld (ix+#39),#f0
	jr l81a1
.l816d
	ld (ix+#18),b
	ld (ix+#1b),b
	bit 0,(ix+#6f)
	jr nz,l81a1
	bit 7,(ix+#33)
	ld (ix+#33),a
	jr nz,l8194
	ld c,(ix+#1e)
	ld (ix+#21),c
	ld (ix+#39),b
	ld (ix+#36),b
	ld c,(ix+#3c)
	ld (ix+#6c),c
.l8194
	ld c,b
	sub #54
	jr c,l819e
	ld c,#02
	ld (l802f),a
.l819e
	ld (ix+#00),c
.l81a1
	ld a,(ix+#30)
	ld (ix+#2d),a
	ld (ix+#06),d
	ld (ix+#03),e
	ret
.l81ae
	ld c,(ix+#75)
.l81b1
	ld a,(ix+#39)
	cp #f0
	ld d,#00
	ret nc
	sub #10
	ld (ix+#39),a
	ret nc
	ld hl,l850b
	ld e,(ix+#6c)
	add hl,de
	ld a,(hl)
	add (ix+#36)
	ld e,a
	add hl,de
	ld a,(hl)
	inc (ix+#36)
	ld (ix+#39),a
	ret
.l81d4
	ld (ix+#6f),b
	ld (ix+#39),#f0
	ret
.l81dc
	ret m
	cp (ix+#69)
	jr z,l81e7
	dec (ix+#69)
	jr z,l81d4
.l81e7
	ld a,(ix+#54)
	ld hl,l872f
	add a
	ld c,a
	add a
	add a
	add hl,bc
	ld c,a
	add hl,bc
	add hl,bc
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	push hl
	ld l,(ix+#63)
	ld h,(ix+#66)
	add hl,de
	ex de,hl
	pop hl
	push hl
	ld c,#07
	add hl,bc
	ld a,(hl)
	dec hl
	ld c,(hl)
	dec (ix+#5a)
	jr nz,l8221
	ld (ix+#5a),a
	rrc (ix+#5d)
	jr c,l821a
	dec hl
	dec hl
.l821a
	dec hl
	ld a,(hl)
	dec hl
	ld l,(hl)
	ld h,a
	add hl,de
	ex de,hl
.l8221
	dec (ix+#57)
	pop hl
	jr nz,l822d
	ld (ix+#57),c
	ld e,(hl)
	inc hl
	ld d,(hl)
.l822d
	ld (ix+#63),e
	ld (ix+#66),d
	ld a,e
	rrc (ix+#60)
	res 0,(ix+#00)
	jr nc,l8244
	inc (ix+#00)
	ld (l803d),a
.l8244
	ex de,hl
	call l831a
	call l81ae
	and #0f
	jp l8324
.l8250
	inc lx
.l8252
	sub a
	ld b,a
	cp (ix+#6f)
	jr nz,l81dc
.music_end equ $ + 1
.l825a equ $ + 1
	cp #00
	ld c,(ix+#75)
	jp z,l8324
	call l81b1
	or #f0
	add #0f
	inc a
	jr c,l826c
	sub a
.l826c
	call l8324
	ld hl,l84fb
	ld e,(ix+#21)
	inc e
	add hl,de
	ld a,(hl)
	or a
	jp p,l8285
	inc a
	jr z,l8288
	ld e,(ix+#1e)
	dec a
	and #7f
.l8285
	ld (ix+#21),e
.l8288
	add (ix+#33)
	add (ix+#48)
	add a
	ld hl,l840c
	ld e,a
	add hl,de
	ld e,(hl)
	inc l
	ld d,(hl)
	ld c,(ix+#4b)
	bit 4,c
	jr z,l82c9
	sub a
	or (ix+#42)
	jr nz,l82a6
	inc a
	and c
.l82a6
	ld b,(ix+#3f)
	ld l,a
	ld a,(ix+#45)
	bit 5,c
	jr nz,l82b8
	sub l
	jr nz,l82be
	set 5,c
	jr l82be
.l82b8
	add l
	cp b
	jr nz,l82be
	res 5,c
.l82be
	ld (ix+#45),a
	srl b
	sub b
	ld l,a
	sbc a
	ld h,a
	add hl,de
	ex de,hl
.l82c9
	ld a,c
	xor #01
	ld (ix+#4b),a
	bit 3,c
	jr z,l82f2
	ld b,(ix+#2a)
	djnz l82ef
	ld c,(ix+#24)
	ld b,(ix+#27)
	ld l,(ix+#18)
	ld h,(ix+#1b)
	add hl,bc
	ld (ix+#18),l
	ld (ix+#1b),h
	add hl,de
	ex de,hl
	jr l82f2
.l82ef
	ld (ix+#2a),b
.l82f2
	cpl
	and #03
	ld a,(ix+#00)
	ld c,a
	res 0,c
	rra
	jr nz,l8305
	ld hl,l803d
.l8302 equ $ + 1
	ld (hl),#10
	or #01
.l8305
	or c
	bit 2,(ix+#4b)
	jr z,l8310
	res 1,(ix+#4b)
.l8310
	ld (ix+#00),a
	ld l,(ix+#4e)
	ld h,(ix+#51)
	add hl,de
.l831a
	ld e,(ix+#72)
	ld a,l
	call l8323
	ld a,h
.l8322
	inc e
.l8323
	ld c,e
.l8324
	ld b,#f4
	out (c),c
	ld bc,#f6c0
	out (c),c
	ld c,#00
	out (c),c
	ld b,#f4
	out (c),a
	ld b,#f6
	ld a,#81
	out (c),a
	out (c),c
	ret
;
.init_music
;
	push af
	call l8060
	pop af
	push bc
	push de
	push hl
	ld de,l8395
	ld bc,#0071
	ld hl,l8394
	push hl
	ld (hl),b
	ldir
	ld hl,l84ea
	ld a,(hl)
	inc hl
	ld (l8016),a
	ex (sp),ix
	ld bc,#0301
	ld a,#ff
	ld (l801a),a
.l8365
	ld a,(hl)
	ld (ix+#0f),a
	inc hl
	ld a,(hl)
	ld (ix+#12),a
	inc hl
	ld e,(hl)
	inc hl
	ld d,(hl)
	inc hl
	ld (ix+#2d),c
	ld (ix+#09),e
	ld (ix+#0c),d
	ld a,(de)
	ld (ix+#03),a
	inc e
	ld a,(de)
	ld (ix+#06),a
	inc lx
	djnz l8365
	pop ix
	ld hl,l825a
	ld (hl),c
	pop hl
	pop de
	pop bc
	ret
.l8396 equ $ + 3
.l8395 equ $ + 2
.l8394 equ $ + 1
	db #20,#53,#4e,#44,#20,#4d,#6f,#64
	db #75,#6c,#65,#20,#28,#43,#29,#20
	db #31,#39,#38,#36,#2d,#31,#39,#38
	db #38,#20,#4a,#61,#73,#2e,#43,#2e
	db #42,#72,#6f,#6f,#6b,#65,#2e,#20
	db #54,#68,#69,#73,#20,#76,#65,#72
	db #73,#69,#6f,#6e,#20,#77,#61,#73
	db #20,#63,#6f,#6d,#70,#6c,#65,#74
	db #65,#64,#20,#32,#30,#74,#68,#20
	db #4a,#75,#6c,#79,#20,#31,#39,#38
	db #38,#2e,#20,#46,#69,#72,#73,#74
	db #20,#76,#65,#72,#73,#69,#6f,#6e
	db #20,#77,#72,#69,#74,#74,#65,#6e
	db #20,#4a,#75,#6e,#65,#20,#31,#39
.l8403
	db #38,#38,#2e
.l8407 equ $ + 1
	db #00,#02,#04,#08,#09,#0a
.l840c
	dw #0777,#070c,#06a7,#0647
	dw #05ed,#0598,#0547,#04fc
	dw #04b4,#0470,#0431,#03f4
	dw #03bc,#0386,#0353,#0324
	dw #02f6,#02cc,#02a4,#027e
	dw #025a,#0238,#0218,#01fa
	dw #01de,#01c3,#01aa,#0192
	dw #017b,#0166,#0152,#013f
	dw #012d,#011c,#010c,#00fd
	dw #00ef,#00e1,#00d5,#00c9
	dw #00be,#00b3,#00a9,#009f
	dw #0096,#008e,#0086,#007f
	dw #0077,#0071,#006a,#0064
	dw #005f,#0059,#0054,#0050
	dw #004b,#0047,#0043,#003f
	dw #003c,#0038,#0035,#0032
	dw #002f,#002d,#002a,#0028
	dw #0026,#0024,#0022,#0020
	dw #001e,#001c,#001b,#0019
	dw #0018,#0016,#0015,#0014
	dw #0013,#0012,#0011,#0010
.l84b4
	dw l8554,l8554,l8554,l8554
.l84be equ $ + 2
	dw l86fd,l8619,l8619,l861c
	dw l861c,l8677,l8677,l8677
	dw l8677,l8619,l861c,l86fd
.l84d4
	dw l85f0,l85ee,l86b5,l86b5
	dw l85f0,l865e,l8677,l8677
	dw l8677,l8677,l86fb
.l84ea
	db #40,#0a,#00
	dw l84b4
	db #16,#00
	dw l84be
	db #16,#00
	dw l84d4
.l84fb equ $ + 4
	db #00,#01,#05,#09,#0d,#80,#00,#04
	db #0c,#87,#00,#03,#0c,#87,#00,#0a
.l850b equ $ + 4
	db #10,#87,#00,#8c,#08,#0e,#16,#22
	db #26,#29,#2f,#38,#1a,#09,#08,#07
	db #06,#05,#f4,#0b,#1e,#1c,#1b,#1a
	db #09,#08,#07,#f6,#2e,#1c,#1b,#1a
	db #49,#18,#17,#16,#15,#14,#13,#12
	db #f1,#0f,#4e,#4c,#3b,#fa,#19,#18
	db #07,#f6,#1d,#1c,#1b,#19,#08,#07
	db #f0,#1b,#1a,#19,#18,#15,#24,#13
	db #32,#21,#f0,#0b,#0a,#07,#06,#05
.l8554 equ $ + 5
	db #14,#03,#02,#11,#f0,#e3,#86,#02
	db #04,#8d,#fc,#7f,#8b,#14,#c1,#10
	db #8a,#10,#c4,#10,#c1,#8a,#10,#8a
	db #10,#8a,#10,#c4,#10,#c1,#8a,#10
	db #8a,#19,#8a,#19,#c4,#19,#c1,#8a
	db #19,#8a,#19,#8a,#19,#c4,#19,#c1
	db #8a,#19,#8a,#12,#8a,#12,#c4,#12
	db #c1,#8a,#12,#8a,#12,#8a,#12,#c4
	db #12,#c1,#8a,#12,#8a,#17,#8a,#17
	db #c4,#17,#c1,#8a,#17,#8a,#17,#8a
	db #17,#c4,#8a,#17,#c1,#8a,#17,#c1
	db #8a,#10,#8a,#10,#c4,#10,#c1,#8a
	db #10,#8a,#10,#8a,#10,#c4,#10,#c1
	db #8a,#10,#8a,#19,#8a,#19,#c4,#19
	db #c1,#8a,#19,#8a,#19,#8a,#19,#c4
	db #19,#c1,#8a,#19,#8a,#12,#8a,#12
	db #c4,#12,#c1,#8a,#12,#8a,#12,#8a
	db #12,#c4,#12,#c1,#8a,#12,#8a,#17
	db #8a,#17,#c4,#17,#c1,#17,#e1,#17
.l85ee equ $ + 7
	db #17,#80,#15,#e3,#14,#12,#85,#89
.l85f0 equ $ + 1
	db #0c,#b0,#e3,#c1,#86,#01,#02,#04
	db #04,#80,#04,#04,#04,#80,#04,#0d
	db #0d,#80,#0d,#0d,#0d,#80,#0d,#06
	db #06,#80,#06,#06,#b2,#12,#12,#b0
	db #06,#0b,#0b,#80,#0b,#0b,#0b,#80
.l861c equ $ + 5
.l8619 equ $ + 2
	db #0b,#85,#b0,#c2,#81,#e1,#1c,#23
	db #23,#20,#e3,#23,#e1,#20,#20,#23
	db #e3,#25,#e5,#23,#e1,#23,#23,#e3
	db #25,#20,#e1,#20,#e3,#21,#82,#02
	db #00,#08,#e3,#20,#e1,#1e,#eb,#1c
	db #e3,#1e,#1e,#e1,#1e,#e3,#21,#e5
	db #20,#e3,#1e,#1e,#80,#e3,#1e,#1e
	db #e1,#1e,#e3,#21,#e5,#20,#e3,#1e
.l865e equ $ + 7
	db #1c,#1b,#c3,#86,#01,#01,#85,#e3
	db #80,#c6,#b1,#e7,#28,#28,#28,#28
	db #b2,#31,#31,#31,#31,#2a,#2a,#2a
	db #2a,#b3,#2f,#2f,#2f,#e3,#2f,#85
.l8677
	db #e3,#89,#00,#b0,#c5,#82,#d8,#7f
	db #01,#15,#82,#d8,#7f,#01,#15,#c7
	db #68,#e1,#80,#68,#72,#e3,#68,#e1
	db #68,#87,#72,#62,#62,#62,#e3,#c5
	db #82,#d8,#7f,#01,#15,#82,#d8,#7f
	db #01,#15,#82,#d8,#7f,#01,#15,#c7
	db #e1,#80,#68,#72,#e3,#68,#e1,#68
.l86b5 equ $ + 6
	db #87,#72,#61,#61,#61,#85,#89,#00
	db #c0,#e1,#b4,#28,#2a,#2c,#2f,#2d
	db #2c,#2a,#29,#28,#2a,#2c,#2f,#2d
	db #2c,#28,#27,#25,#27,#28,#2c,#2a
	db #28,#27,#26,#25,#27,#28,#2c,#2a
	db #28,#25,#23,#21,#20,#1e,#20,#21
	db #23,#25,#23,#21,#20,#1e,#20,#21
	db #23,#25,#24,#23,#25,#27,#2a,#28
	db #27,#25,#24,#23,#25,#27,#2a,#28
.l86fd equ $ + 6
.l86fb equ $ + 4
	db #25,#23,#21,#85,#89,#f4,#c5,#e3
	db #10,#e2,#19,#e0,#10,#e3,#10,#e2
	db #17,#e0,#10,#e3,#10,#e2,#19,#e0
	db #10,#e3,#10,#e2,#17,#e0,#10,#e3
	db #10,#e2,#19,#e0,#10,#e3,#10,#e2
	db #17,#e0,#10,#e3,#10,#e1,#17,#e3
	db #19,#e1,#17,#14,#12,#89,#00,#85
.l872f
	db #00,#00

;org #8c32
;call #833e; init music

.game_name
	db "Hopper Copper",0
.game_year
	db "1989",0
.game_publisher
	db "Firebird",0
.music_author
	db "Jason C. Brooke",0
.music_comment
	db "SND Module (C) 1986-1988 Jas.C.Brooke. This version was completed 20th July 1988. First version written June 1988",0

	read "music_end_v1_0.asm"
